﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;
public partial class Bidder_SuitTestimony : System.Web.UI.Page
{
   
    string AccountId,Accounttype="";
    public string pubaaa = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        string strSql, Id;
        if (HZ.MBSM.BLL.Login.CheckAssert(this.UseAccountType))
        {
            HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
            if (_Account != null)
            {
                Accounttype = _Account.Type;
                AccountId = SysFun.ToTrim(_Account.AccountId);
                if (Accounttype == "1")
                {
                    pubaaa = "<a target=\"_blank\" href='../HomePage/Boardinfo.aspx?Id=<%# DataBinder.Eval(Container.DataItem, \"ID\")%>'>回复 </a>";
                }
                else
                {
                    pubaaa = "<a target=\"_blank\" href='../HomePage/Boardinfo.aspx?Id=<%# DataBinder.Eval(Container.DataItem, \"ID\")%>'>查看回复 </a>";
                }
                if (Request.Form["btnSubmit"] == "删除" && Request.Form["chk"] != null)
                {
                    Id = Request.Form["chk"].ToString();
                    strSql = "delete from board where Id in (" + Id + ")";
                    Db db = new Db();
                    db.Command(strSql);
                    db.Close();
                    // HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
                    HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "删除", "board", strSql, "../Bidder/BoardList.aspx");

                }
                ShowDate();
            }
        }
    }

    public void ShowDate()
    {
        string strConditions;
        strConditions = fctConditions();
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "SuitTestimony ";                                               //要查询的表明
        dbPage.Key = "id";                                               //表的主键    
        dbPage.Where = strConditions;                                           //查询条件    
        dbPage.SelectField = "id,TWname,Title,TwTime,case sort when 1 then '投诉' when 2 then '申述'end as sort,AnswerDate";//要显示的字段
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   
        dbPage.PageSize = 10;                                                    //没有显示记录条数   
        dbPage.OrderBy = "id";                  //排序字段
        System.Data.IDataReader dr = dbPage.ExecuteReader();
        DlLaw.DataSource = dr;
        DlLaw.DataBind();
        dr.Close();
       // dr.Dispose();
        dbPage.Db.Close(); 
        db.Close();

        dr = null;
        db = null;
        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键 
    }
    /// <summary>
    /// 生成查询条件
    /// </summary>
    /// <returns></returns>
    public string fctConditions()
    {
        string strtemp = "", Title;
        Title = txtTitle.Text.ToString().Trim();
        if (Accounttype != "1")
        {
            strtemp = " SuitTestimony.AccountId=" + AccountId;

            if (Title != "")
            {
                strtemp += "  and Title like '%" + Title + "%' ";
            }
        }//下面的else是 08.11 增加的，以使得zbzx的身份，投诉申诉的查询功能发挥作用
        else
        {
            if (Title != "")
            {
                strtemp += " Title like '%" + Title + "%' ";
            }
        }
       
        return strtemp;

    }

    #region IPageDescribe 成员


    public string Describe
    {
        get { return ""; }
    }
    public string Name
    {
        get { return "问题列表"; }
    }
    public string ParentName
    {
        get { return "问题反馈"; }
    }

    public System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> UseAccountType
    {
        get
        {
            System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumCompany);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumHospitale);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
            return _AccountType;
        }
    }

    #endregion

    protected void DlLaw_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (Accounttype == "1")
            {
                e.Row.Cells[6].Text = "<a target=\"_blank\" href='SuitTestimonyReply.aspx?Id=" + e.Row.Cells[0].Text + "'>回复 </a>";
            }
            else
            {
                e.Row.Cells[6].Text = "<a target=\"_blank\" href='SuitTestimonyInfo.aspx?Id=" + e.Row.Cells[0].Text + "'>查看回复 </a>";
            }
        }
    }
}
